package rootPackage.controller.creazione.dbRicette;

import java.util.List;

import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;
import org.slim3.datastore.Datastore;
import org.slim3.util.BeanUtil;

import rootPackage.model.Prodotti;
import rootPackage.model.Ricette;
import rootPackage.service.ProdottiService;
import rootPackage.service.RicetteService;

public class ModificaController extends Controller {
    
    private RicetteService service = new RicetteService();
    private ProdottiService prod=new ProdottiService();

    @Override
    public Navigation run() throws Exception {
        List<Prodotti>elenco = prod.getAll();
        requestScope("elenco", elenco);
        String chiave=request.getQueryString();
        Ricette ricette = service.get(Datastore.stringToKey((chiave)));
        BeanUtil.copy(ricette, request);
        return forward("Modifica.jsp");
    }
}